package hanelsoft.vn.dictionaylearn.control.custom;

import hanelsoft.vn.dictionaylearn.R;
import hanelsoft.vn.dictionaylearn.model.entity.InfoHistory;

import java.util.ArrayList;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class CustomHistory extends ArrayAdapter<InfoHistory>{
	Activity context;
	ArrayList<InfoHistory> list;
	InfoHistory info;
	public CustomHistory(Activity context, ArrayList<InfoHistory> objects) {
		super(context, R.layout.custom_history_row, objects);
		this.context = context;
		this.list = objects;
	}
	class ViewHolder
	{
		TextView itemHistory;
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View rowView;
		if(convertView == null)
		{
			LayoutInflater mLayoutInflater = context.getLayoutInflater();
			rowView = mLayoutInflater.inflate(R.layout.custom_history_row, null);
			ViewHolder mViewHolder = new ViewHolder();
			mViewHolder.itemHistory = (TextView)rowView.findViewById(R.id.custom_history_row_item);
			rowView.setTag(mViewHolder);
		}
		else
		{
			rowView = convertView;
		}
		ViewHolder holder = (ViewHolder)rowView.getTag();
		info = list.get(position);
		holder.itemHistory.setText(info.getWord());
		return rowView;
	}
}
